#include "StdAfx.h"
#include "HeartbeatPacket.h"

CHeartbeatPacket::CHeartbeatPacket(UINT32 id)
: m_pPacket(new char[GetLength()])
{
	Header_Struct* head = (Header_Struct*)m_pPacket;
	head->ver = 1;
	head->subver = 0;
	head->protype = PACKET_PROTYPE_NET;
	head->subprotype = adChannelPacketTypeClientHeartBeat;
	head->id = id;
	head->timestamp = 0;
	head->length = PACKET_DATA_SIZE;

	*((UINT16*)(m_pPacket + PACKET_HEADER_SIZE + 0)) = 0;
	*((UINT16*)(m_pPacket + PACKET_HEADER_SIZE + 2)) = 1;
	*((UINT16*)(m_pPacket + PACKET_HEADER_SIZE + 4)) = 2;
	*((UINT16*)(m_pPacket + PACKET_HEADER_SIZE + 6)) = 3;
}

CHeartbeatPacket::~CHeartbeatPacket(void)
{
	delete[] m_pPacket;
}

const char* CHeartbeatPacket::GetPacket() const
{
	return m_pPacket;
}
